package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.hnkywl.sts.dao.report.BgjhdxlDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: ccr
 * Date: 13-8-6
 * Time: 下午8:37
 * To change this template use File | Settings | File Templates.
 */
@Service
public class BgjhdxlService {

    private BgjhdxlDao bgjhdxlDao;

    public String bgjhdxlList(Integer nf,Integer yf,String jhlx,Long jhdw,Long gyz,String wzbm, String jhsm,Integer pageNo, Integer pageSize){
        Map result = bgjhdxlDao.bgjhdxlList(nf,yf,jhlx,jhdw,gyz,wzbm,jhsm,pageNo,pageSize);
        List<Map> rows = (List<Map>)result.get("rows");
        int total = (Integer) result.get("total");
        return "{\"total\":"+total+",\"rows\":"+new Gson().toJson(rows)+"}";
    }

    public String existsJhsm(String jhsm) {
        String sql = "select * from t_biz_bgjhhz where sm = ?";
        if(bgjhdxlDao.existsSQLQuery(sql,jhsm)){
            return "ok";
        } else {
            return "no";
        }
    }

    public List<Map> bgjhdxlExp(Integer nf,Integer yf,String jhlx,Long jhdw,Long gyz,String wzbm, String jhsm){
        Map result = bgjhdxlDao.bgjhdxlList(nf,yf,jhlx,jhdw,gyz,wzbm,jhsm,1,10000);
        List<Map> rows = (List<Map>)result.get("rows");
        return rows;
    }

    @Autowired
    public void setBgjhdxlDao(BgjhdxlDao bgjhdxlDao) {
        this.bgjhdxlDao = bgjhdxlDao;
    }
}
